//
//  MyExploreVC.m
//  echo
//
//  Created by dllo on 16/1/22.
//  Copyright © 2016年 Danny. All rights reserved.
//

#define WIDTH [UIScreen mainScreen].bounds.size.width / 414
#define HEIGHT [UIScreen mainScreen].bounds.size.height / 736

#import "MyExploreVC.h"
#import "NetworkingHandler.h"
#import "ModelForMyExploreTableViewHeader.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import "CellForMyExploreTableViewSectionZeroAndTwo.h"
#import "CellForMyExploreTableViewSectionOne.h"
#import "CellForMyExploreTableViewSectionThreeAndFour.h"
#import "ModelOfCellForMyExploreTableViewSectionZero.h"
#import "ModelOfCellForMyExploreTableViewSectionOne.h"
#import "ModelOfCellForMyExploreTableViewSectionOne2.h"
#import "ModelOfCellForMyExploreTableViewSectionTwo.h"
#import "ModelOfCellForMyExploreTableViewSectionThreeAndFour.h"
#import "VideoPlayerVC.h"
#import "SearchVC.h"
#import <DKNightVersion.h>
#import "SQLHandler.h"
#import "ModelOfCellForClassifyVCSectionOneToNine.h"
#import "InformationVC.h"

@interface MyExploreVC ()<UITableViewDataSource, UITableViewDelegate, CellForMyExploreTableViewSectionThreeAndFour>
@property (nonatomic, retain)UITableView *tableView;
@property (nonatomic, retain)UIView *viewOfBack;
@property (nonatomic, retain)UIImageView *imageViewForHeader;
@property (nonatomic, retain)NSMutableArray *arrForTableViewHeader;
@property (nonatomic, retain)NSMutableArray *arrForTableViewSectionZero;
@property (nonatomic, retain)NSMutableArray *arrForTableViewSectionOne;
@property (nonatomic, retain)NSMutableArray *arrForTableViewSectionOne2;
@property (nonatomic, retain)NSMutableArray *arrForTableViewSectionTwo;
@property (nonatomic, retain)NSMutableArray *arrForTableViewSectionThree;
@property (nonatomic, retain)NSMutableArray *arrForTableViewSectionFour;
@property (nonatomic, retain)NSMutableArray *arrForMyExploreSectionOneLeftVideo;
@property (nonatomic, retain)NSMutableArray *arrForMyExploreSectionOneRightVideo;
@property (nonatomic, retain)UIButton *buttonForSearch;
@end

@implementation MyExploreVC

- (void)dealloc{
    [_viewOfBack release];
    [_imageViewForHeader release];
    [_arrForTableViewHeader release];
    [_arrForTableViewSectionZero release];
    [_arrForTableViewSectionOne release];
    [_arrForTableViewSectionOne2 release];
    [_arrForTableViewSectionTwo release];
    [_arrForTableViewSectionThree release];
    [_arrForTableViewSectionFour release];
    [_arrForMyExploreSectionOneLeftVideo release];
    [_arrForMyExploreSectionOneRightVideo release];
    [_buttonForSearch release];
    self.tableView.delegate = nil;
    [_tableView release];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"postModelForMyExploreSectionZero" object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"postModelForMyExploreSectionTwo" object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"postModelForMyExploreVCLeft" object:nil];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"postModelForMyExploreVCRight" object:nil];
    [super dealloc];
    NSInteger index = self.tabBarController.selectedIndex;
    UINavigationController *navi = [self.tabBarController.viewControllers objectAtIndex:index -1];

    NSLog(@"第四页%@", navi);
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.hidesBackButton = YES;
    [self handleDataForTableViewHeader];
    self.automaticallyAdjustsScrollViewInsets = NO;
    [[NSNotificationCenter defaultCenter] addObserverForName:@"postModelForMyExploreSectionZero" object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
        InformationVC *vc = [[InformationVC alloc]init];
        ModelOfCellForMyExploreTableViewSectionZero *model = [note.userInfo objectForKey:@"model"];
        vc.id = model.id;
        [self.navigationController pushViewController:vc animated:YES];
    }];
    [[NSNotificationCenter defaultCenter] addObserverForName:@"postModelForMyExploreSectionTwo" object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
        InformationVC *vc = [[InformationVC alloc]init];
        ModelOfCellForMyExploreTableViewSectionTwo *model = [note.userInfo objectForKey:@"model"];
        vc.id = model.id;
        [self.navigationController pushViewController:vc animated:YES];
    }];
}

- (void)handleDataForTableViewHeader{
    [NetworkingHandler networkingGetWithUrl:@"http://echosystem.kibey.com/index/banner?position=3" dicForValue:@{@"User-Agent":@"echo ios 3.7.3 20160209;(iPhone,iPhone OS9.2.1);IDFA F37139C2-85EF-45C8-B64D-2D16D2772A96 Paros/3.2.13" ,@"x-v":@"20160209", @"x-c":@"3"} completeHandle:^(id result) {
        NSArray *arr = [result objectForKey:@"result"];
        self.arrForTableViewHeader = [NSMutableArray array];
        for (NSDictionary *dic in arr) {
            ModelForMyExploreTableViewHeader *model = [[ModelForMyExploreTableViewHeader alloc]init];
            NSDictionary *tempDic = [dic objectForKey:@"sound"];
            model.source = [tempDic objectForKey:@"source"];
            [model setValuesForKeysWithDictionary:dic];
            [self.arrForTableViewHeader addObject:model];
            [model release];
            
        }
        [self handleDataOfCellForTableViewSectionZero];
    }];

}

- (void)handleDataOfCellForTableViewSectionZero{
    [NetworkingHandler networkingGetWithUrl:@"http://echosystem.kibey.com/echofamous/music-video/users?version=1&hot_sounds_limit=3" dicForValue:@{@"x-v":@"20160209", @"x-c":@"3"} completeHandle:^(id result) {
        
        NSDictionary *dic = [result objectForKey:@"result"];
        NSArray *arr = [dic objectForKey:@"top_users"];
        self.arrForTableViewSectionZero = [NSMutableArray array];
        for (NSDictionary *tempDic in arr) {
            ModelOfCellForMyExploreTableViewSectionZero *model = [[ModelOfCellForMyExploreTableViewSectionZero alloc]init];
            [model setValuesForKeysWithDictionary:tempDic];
            [self.arrForTableViewSectionZero addObject:model];
            [model release];
        }
//        [self handleDataOfCellForTableViewSectionOne];
        [self handleDataForVideoOfSectionOneLeft];
    }];

}

- (void)handleDataForVideoOfSectionOneLeft{
    [NetworkingHandler networkingGetWithUrl:@"http://echosystem.kibey.com/echofamous/music-video/info?id=216" dicForValue:@{@"x-v":@"20160209",@"x-c":@"3",@"Cookie":@"PHPSESSID=71gp9k5ngngg51mhah3bbnmhq7"} completeHandle:^(id result) {
        NSDictionary *dic = [result objectForKey:@"result"];
        self.arrForMyExploreSectionOneLeftVideo = [NSMutableArray array];
        ModelOfCellForMyExploreTableViewSectionOne *model = [[ModelOfCellForMyExploreTableViewSectionOne alloc]init];
        [model setValuesForKeysWithDictionary:dic];
        NSDictionary *dic2 = [dic objectForKey:@"user"];
        model.nameForBottom = [dic2 objectForKey:@"name"];
        [self.arrForMyExploreSectionOneLeftVideo addObject:model];

        [model release];

        [self handleDataForVideoOfSectionOneRight];
    }];
}

- (void)handleDataForVideoOfSectionOneRight{
    [NetworkingHandler networkingGetWithUrl:@"http://echosystem.kibey.com/echofamous/music-video/info?id=211" dicForValue:@{@"x-v":@"20160209",@"x-c":@"3",@"Cookie":@"PHPSESSID=71gp9k5ngngg51mhah3bbnmhq7"} completeHandle:^(id result) {
        NSDictionary *dic = [result objectForKey:@"result"];
        self.arrForMyExploreSectionOneRightVideo = [NSMutableArray array];
        ModelOfCellForMyExploreTableViewSectionOne *model = [[ModelOfCellForMyExploreTableViewSectionOne alloc]init];
        [model setValuesForKeysWithDictionary:dic];
        NSDictionary *dic2 = [dic objectForKey:@"user"];
        model.nameForBottom = [dic2 objectForKey:@"name"];
        [self.arrForMyExploreSectionOneRightVideo addObject:model];
        
        [model release];
        
        [self handleDataOfCellForTableViewSectionTwo];
    }];
}

- (void)handleDataOfCellForTableViewSectionTwo{
    [NetworkingHandler networkingGetWithUrl:@"http://echosystem.kibey.com/echofamous/music-video/users?version=1&hot_sounds_limit=3" dicForValue:@{@"x-v":@"20160209", @"x-c":@"3"} completeHandle:^(id result) {
        NSDictionary *dic = [result objectForKey:@"result"];
        NSArray *arr = [dic objectForKey:@"latest_users"];
        self.arrForTableViewSectionTwo = [NSMutableArray array];
        for (NSDictionary *tempDic in arr) {
            ModelOfCellForMyExploreTableViewSectionTwo *model = [[ModelOfCellForMyExploreTableViewSectionTwo alloc]init];
            [model setValuesForKeysWithDictionary:tempDic];
            [self.arrForTableViewSectionTwo addObject:model];
            [model release];
        }
        [self handleDataOfCellForTableViewSectionThree];
        
    }];

}

- (void)handleDataOfCellForTableViewSectionThree{
    [NetworkingHandler networkingGetWithUrl:@"http://echosystem.kibey.com/echofamous/music-video/users?version=1&hot_sounds_limit=3" dicForValue:@{@"x-v":@"20160209", @"x-c":@"3"} completeHandle:^(id result) {
        NSDictionary *dic = [result objectForKey:@"result"];
        NSArray *arr = [dic objectForKey:@"famous_users"];
        NSDictionary *tempDic = [arr objectAtIndex:0];
        NSArray *arr2 = [tempDic objectForKey:@"users"];
        self.arrForTableViewSectionThree = [NSMutableArray array];
        for (NSDictionary *tempDic2 in arr2) {
            ModelOfCellForMyExploreTableViewSectionThreeAndFour *model = [[ModelOfCellForMyExploreTableViewSectionThreeAndFour alloc]init];
            [model setValuesForKeysWithDictionary:tempDic2];
            [self.arrForTableViewSectionThree addObject:model];
            [model release];
        }
        [self handleDataOfCellForTableViewSectionFour];
        
    }];
}

- (void)handleDataOfCellForTableViewSectionFour{
    [NetworkingHandler networkingGetWithUrl:@"http://echosystem.kibey.com/echofamous/music-video/users?version=1&hot_sounds_limit=3" dicForValue:@{@"x-v":@"20160209", @"x-c":@"3"} completeHandle:^(id result) {
        NSDictionary *dic = [result objectForKey:@"result"];
        NSArray *arr = [dic objectForKey:@"famous_users"];
        self.arrForTableViewSectionFour = [NSMutableArray array];
        NSDictionary *tempDic = [arr objectAtIndex:1];
        NSArray *tempArr = [tempDic objectForKey:@"users"];
        for (NSDictionary *tempDic2 in tempArr) {
            ModelOfCellForMyExploreTableViewSectionThreeAndFour *model = [[ModelOfCellForMyExploreTableViewSectionThreeAndFour alloc]init];
            [model setValuesForKeysWithDictionary:tempDic2];
            [self.arrForTableViewSectionFour addObject:model];
            [model release];
        }
        
//        [self handleDataForVideoOfSectionOne];
        [self createTableView];
        
    }];

}

- (void)createTableView{
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height - 64 - 44) style:UITableViewStyleGrouped];
    self.tableView.dk_backgroundColorPicker = DKColorWithColors([UIColor whiteColor], [UIColor colorWithRed:17 / 256.f green:27 / 256.f blue:47 / 256.f alpha:1]);
    [self.view addSubview:self.tableView];
    [self.tableView release];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.showsVerticalScrollIndicator = NO;
    self.viewOfBack = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 160 * HEIGHT)];
    self.viewOfBack.dk_backgroundColorPicker = DKColorWithColors([UIColor colorWithRed:218 / 255.f green:219 / 255.f blue:216 / 255.f alpha:1], [UIColor colorWithRed:17 / 256.f green:27 / 256.f blue:47 / 256.f alpha:1]);
    self.imageViewForHeader = [[UIImageView alloc]initWithFrame:CGRectMake(10 * WIDTH, 10 * HEIGHT, self.view.frame.size.width - 20 * WIDTH, 140 * HEIGHT)];
   
    ModelForMyExploreTableViewHeader *model = [[ModelForMyExploreTableViewHeader alloc]init];
    model = [self.arrForTableViewHeader lastObject];
    [self.imageViewForHeader sd_setImageWithURL:[NSURL URLWithString:model.pic]];
    [self.viewOfBack addSubview:self.imageViewForHeader];
    [self.imageViewForHeader release];
    [model release];

    // 未release viewOfBack
    self.tableView.tableHeaderView = self.viewOfBack;
    
    self.tableView.showsVerticalScrollIndicator = NO;
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"pool1"];
    [self.tableView registerClass:[CellForMyExploreTableViewSectionZeroAndTwo class] forCellReuseIdentifier:@"poolForSectionZeroAndTwo0"];
    [self.tableView registerClass:[CellForMyExploreTableViewSectionOne class] forCellReuseIdentifier:@"poolForSectionOne"];
    [self.tableView registerClass:[CellForMyExploreTableViewSectionZeroAndTwo class] forCellReuseIdentifier:@"poolForSectionZeroAndTwo2"];
    [self.tableView registerClass:[CellForMyExploreTableViewSectionThreeAndFour class] forCellReuseIdentifier:@"poolForSectionThree"];
    [self.tableView registerClass:[CellForMyExploreTableViewSectionThreeAndFour class] forCellReuseIdentifier:@"poolForSectionFour"];
    
    [[NSNotificationCenter defaultCenter] addObserverForName:@"postModelForMyExploreVCLeft" object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
        VideoPlayerVC *vc = [[VideoPlayerVC alloc]init];
        ModelOfCellForMyExploreTableViewSectionOne *model = [note.userInfo objectForKey:@"model"];
        [vc passModelForMyExploreVC:model];
        [self.navigationController pushViewController:vc animated:YES];
        [vc release];
    }];
    
    [[NSNotificationCenter defaultCenter] addObserverForName:@"postModelForMyExploreVCRight" object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
        VideoPlayerVC *vc = [[VideoPlayerVC alloc]init];
        ModelOfCellForMyExploreTableViewSectionOne *model = [note.userInfo objectForKey:@"model"];
        [vc passModelForMyExploreVC:model];
        [self.navigationController pushViewController:vc animated:YES];
        [vc release];
    }];
    
    self.buttonForSearch = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.navigationController.navigationBar addSubview:self.buttonForSearch];
    self.buttonForSearch.frame = CGRectMake(15 * WIDTH, 2.5 * HEIGHT, 35 * WIDTH, 35 * WIDTH);
    [self.buttonForSearch setBackgroundImage:[UIImage imageNamed:@"iconfont-search"] forState:UIControlStateNormal];
    [self.buttonForSearch addTarget:self action:@selector(handleSearch) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)handleSearch{
    SearchVC *searchVC = [[SearchVC alloc]init];
    [self.navigationController pushViewController:searchVC animated:YES];
//    [searchVC release];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    if (self.arrForTableViewSectionFour == nil) {
        return 4;
    }else{
        
        return 5;
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 1;
    }else if (section == 1){
        return 0;
    }else if (section == 2){
        return 1;
    }else if (section == 3){
        return 5;
    }else{
        if (self.arrForTableViewSectionFour != nil) {
            return 3;
        }else{
            return 0;
        }
        
    }
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        UIView *viewOfBackForSectionZero = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 35 * HEIGHT)];
        viewOfBackForSectionZero.dk_backgroundColorPicker = DKColorWithColors([UIColor colorWithRed:218 / 255.f green:219 / 255.f blue:216 / 255.f alpha:1], [UIColor colorWithRed:17 / 256.f green:27 / 256.f blue:47 / 256.f alpha:1]);
        UILabel *labelForSectionZero = [[UILabel alloc]initWithFrame:CGRectMake(10 * WIDTH, 5 * HEIGHT, self.view.frame.size.width - 20 * WIDTH, 35 * HEIGHT)];
        [viewOfBackForSectionZero addSubview:labelForSectionZero];
        [labelForSectionZero release];
        labelForSectionZero.text = @"      echo群星";
        labelForSectionZero.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
        labelForSectionZero.font = [UIFont fontWithName:@"Arial" size:17.0];
    
    return viewOfBackForSectionZero;
    }else if (section == 1){
        UIView *viewOfBackForSectionOne = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40 * HEIGHT)];
        viewOfBackForSectionOne.dk_backgroundColorPicker = DKColorWithColors([UIColor colorWithRed:218 / 255.f green:219 / 255.f blue:216 / 255.f alpha:1], [UIColor colorWithRed:17 / 256.f green:27 / 256.f blue:47 / 256.f alpha:1]);
        UILabel *labelForSectionOne = [[UILabel alloc]initWithFrame:CGRectMake(10 * WIDTH, 5 * HEIGHT, self.view.frame.size.width - 20 * WIDTH, 40 * HEIGHT)];
        [viewOfBackForSectionOne addSubview:labelForSectionOne];
        [labelForSectionOne release];
        labelForSectionOne.text = @"      宣传视频";
        labelForSectionOne.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
        labelForSectionOne.font = [UIFont fontWithName:@"Arial" size:17.0];
        return viewOfBackForSectionOne;
    }else if (section == 2){
        UIView *viewOfBackForSectionTwo = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40 * HEIGHT)];
        viewOfBackForSectionTwo.dk_backgroundColorPicker = DKColorWithColors([UIColor colorWithRed:218 / 255.f green:219 / 255.f blue:216 / 255.f alpha:1], [UIColor colorWithRed:17 / 256.f green:27 / 256.f blue:47 / 256.f alpha:1]);
        UILabel *labelForSectionTwo = [[UILabel alloc]initWithFrame:CGRectMake(10 * WIDTH, 5 * HEIGHT, self.view.frame.size.width - 20 * WIDTH, 40 * HEIGHT)];
        [viewOfBackForSectionTwo addSubview:labelForSectionTwo];
        [labelForSectionTwo release];
        labelForSectionTwo.text = @"      新入驻";
        labelForSectionTwo.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
        labelForSectionTwo.font = [UIFont fontWithName:@"Arial" size:17.0];
        return viewOfBackForSectionTwo;
    }else if (section == 3){
        UIView *viewOfBackForSectionThree = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40 * HEIGHT)];
        viewOfBackForSectionThree.dk_backgroundColorPicker = DKColorWithColors([UIColor colorWithRed:218 / 255.f green:219 / 255.f blue:216 / 255.f alpha:1], [UIColor colorWithRed:17 / 256.f green:27 / 256.f blue:47 / 256.f alpha:1]);
        UILabel *labelForSectionThree = [[UILabel alloc]initWithFrame:CGRectMake(10 * WIDTH, 5 * HEIGHT, self.view.frame.size.width - 20 * WIDTH, 40 * HEIGHT)];
        [viewOfBackForSectionThree addSubview:labelForSectionThree];
        [labelForSectionThree release];
        labelForSectionThree.text = @"      echo推荐";
        labelForSectionThree.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
        labelForSectionThree.font = [UIFont fontWithName:@"Arial" size:17.0];
        return viewOfBackForSectionThree;
    }else{
        UIView *viewOfBackForSectionFour = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40 * HEIGHT)];
        viewOfBackForSectionFour.dk_backgroundColorPicker = DKColorWithColors([UIColor colorWithRed:218 / 255.f green:219 / 255.f blue:216 / 255.f alpha:1], [UIColor colorWithRed:17 / 256.f green:27 / 256.f blue:47 / 256.f alpha:1]);
        UILabel *labelForSectionFour = [[UILabel alloc]initWithFrame:CGRectMake(10 * WIDTH, 5 * HEIGHT, self.view.frame.size.width - 20 * WIDTH, 40 * HEIGHT)];
        [viewOfBackForSectionFour addSubview:labelForSectionFour];
        [labelForSectionFour release];
        labelForSectionFour.text = @"      24小时热门";
        labelForSectionFour.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
        labelForSectionFour.font = [UIFont fontWithName:@"Arial" size:17.0];
        return viewOfBackForSectionFour;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        
        return 35 * HEIGHT;
    }else if (section == 1){
     
        return 0.01 * HEIGHT;
    }else{
        
        return 40 * HEIGHT;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01 * HEIGHT;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return 128.8 * HEIGHT;
    }else if (indexPath.section == 2){
        return 128.8 * HEIGHT;
    }else if (indexPath.section == 1){
        return 160 * HEIGHT;
    }else{
        return 82.8 * HEIGHT;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        CellForMyExploreTableViewSectionZeroAndTwo *cell0= [tableView dequeueReusableCellWithIdentifier:@"poolForSectionZeroAndTwo0"];
        [cell0 passDataOfCellForTableViewSectionZero:self.arrForTableViewSectionZero];
        [cell0 setSelectionStyle:UITableViewCellSelectionStyleNone];
        
        return cell0;
    }else if (indexPath.section == 1){
        CellForMyExploreTableViewSectionOne *cell1 = [tableView dequeueReusableCellWithIdentifier:@"poolForSectionOne"];

        [cell1 passDataOfCellForTableViewSectionOne:self.arrForMyExploreSectionOneLeftVideo];
        [cell1 passDataOfCellForTableViewSectionOne2:self.arrForMyExploreSectionOneRightVideo];
        [cell1 setSelectionStyle:UITableViewCellSelectionStyleNone];
        
        return cell1;
    }else if (indexPath.section == 2){
        CellForMyExploreTableViewSectionZeroAndTwo *cell2 = [tableView dequeueReusableCellWithIdentifier:@"poolForSectionZeroAndTwo2"];
        [cell2 passDataOfCellForTableViewSectionTwo:self.arrForTableViewSectionTwo];
        [cell2 setSelectionStyle:UITableViewCellSelectionStyleNone];
        
        return cell2;
    }else if (indexPath.section == 3){
        CellForMyExploreTableViewSectionThreeAndFour *cell3 = [tableView dequeueReusableCellWithIdentifier:@"poolForSectionThree"];
        [cell3 setSelectionStyle:UITableViewCellSelectionStyleNone];
        cell3.delegate = self;
        if (indexPath.row == 0) {
            ModelOfCellForMyExploreTableViewSectionThreeAndFour *model = [self.arrForTableViewSectionThree objectAtIndex:0];
            [cell3 passDataOfCellForTableViewSectionThreeAndFour:model];
            return cell3;
        }else if (indexPath.row == 1){
            ModelOfCellForMyExploreTableViewSectionThreeAndFour *model = [self.arrForTableViewSectionThree objectAtIndex:1];

            [cell3 passDataOfCellForTableViewSectionThreeAndFour:model];
            return cell3;
        }else if (indexPath.row == 2){
            ModelOfCellForMyExploreTableViewSectionThreeAndFour *model = [self.arrForTableViewSectionThree objectAtIndex:2];

            [cell3 passDataOfCellForTableViewSectionThreeAndFour:model];
            return cell3;
        }else if (indexPath.row == 3){
            ModelOfCellForMyExploreTableViewSectionThreeAndFour *model = [self.arrForTableViewSectionThree objectAtIndex:3];

            [cell3 passDataOfCellForTableViewSectionThreeAndFour:model];
            return cell3;
        }else{
            ModelOfCellForMyExploreTableViewSectionThreeAndFour *model = [self.arrForTableViewSectionThree objectAtIndex:4];

            [cell3 passDataOfCellForTableViewSectionThreeAndFour:model];
            return cell3;
        }
        
    }else{

        if (self.arrForTableViewSectionFour != nil) {
            
            CellForMyExploreTableViewSectionThreeAndFour *cell4 = [tableView dequeueReusableCellWithIdentifier:@"poolForSectionFour"];
            cell4.delegate = self;
            [cell4 setSelectionStyle:UITableViewCellSelectionStyleNone];
            if (indexPath.row == 0) {
                ModelOfCellForMyExploreTableViewSectionThreeAndFour *model = [self.arrForTableViewSectionFour objectAtIndex:0];
                
                [cell4 passDataOfCellForTableViewSectionThreeAndFour:model];
                return cell4;
            }else if (indexPath.row == 1){
                ModelOfCellForMyExploreTableViewSectionThreeAndFour *model = [self.arrForTableViewSectionFour objectAtIndex:1];
                
                [cell4 passDataOfCellForTableViewSectionThreeAndFour:model];
                return cell4;
            }else{
                ModelOfCellForMyExploreTableViewSectionThreeAndFour *model = [self.arrForTableViewSectionFour objectAtIndex:2];
                
                [cell4 passDataOfCellForTableViewSectionThreeAndFour:model];
                return cell4;
            }
        }else{
            return nil;
        }
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.section == 3) {
        ModelOfCellForMyExploreTableViewSectionThreeAndFour *model = [self.arrForTableViewSectionThree objectAtIndex:indexPath.row];
        InformationVC *vc = [[InformationVC alloc]init];
        vc.id = model.id;
        [self.navigationController pushViewController:vc animated:YES];
    }else if (indexPath.section == 4){
        ModelOfCellForMyExploreTableViewSectionThreeAndFour *model = [self.arrForTableViewSectionFour objectAtIndex:indexPath.row];
        InformationVC *vc = [[InformationVC alloc]init];
        vc.id = model.id;
        [self.navigationController pushViewController:vc animated:YES];
    }
    
}

- (void)handleCollectAlert{
    
    UIAlertController *alertForCollect = [UIAlertController alertControllerWithTitle:nil message:@"已收藏" preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *sure = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    
    [alertForCollect addAction:sure];
    
    [self presentViewController:alertForCollect animated:YES completion:^{
    }];

}

- (void)handleDeleteAlert:(NSString *)str{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"是否取消收藏" preferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction *delete = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
    }];
    
    UIAlertAction *quxiao = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        
        [SQLHandler deleteData:str];
        
        [[NSNotificationCenter defaultCenter] postNotificationName:@"alreadyDeleteForClassifyVC" object:nil userInfo:nil];
    }];

    
    [alert addAction:quxiao];
    [alert addAction:delete];
    
    [self presentViewController:alert animated:YES completion:^{
        
    }];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBarHidden = NO;
    self.tabBarController.tabBar.hidden = NO;
    self.navigationController.navigationBar.dk_barTintColorPicker = DKColorWithColors([UIColor whiteColor], [UIColor colorWithRed:13 / 256.f green:19 / 256.f blue:30 / 256.f alpha:1]);
    
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"夜间模式"]) {
        
        [DKNightVersionManager nightFalling];
        
    } else {
        
        [DKNightVersionManager dawnComing];
    }
    self.tabBarController.tabBar.dk_barTintColorPicker = DKColorWithColors([UIColor whiteColor], [UIColor colorWithRed:18 / 256.f green:29 / 256.f blue:50 / 256.f alpha:1]);
    [self.tableView reloadData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
